<!DOCTYPE html>
<html>
  <head>

    <title>Layui</title>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="layui/css/layui.css">
    <!-- <script src="js/jquery-1.4.1.min.js" type="text/javascript"></script> -->
    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
  </head>
  

  <body >
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
      <legend>图片名称</legend>
    </fieldset>
     
    <div class="layui-btn-container" id="content">
    </div>
              



    <script src="layui/layui.js" charset="utf-8"></script>
    <!-- 注意：如果你直接复制所有代码到本地，上述 JS 路径需要改成你本地的 -->
  </body>

<script language="javascript" type="text/javascript">
  		function getQueryVariable(variable)
			{
       			var query = window.location.search.substring(1);
      			 var vars = query.split("&");
       			for (var i=0;i<vars.length;i++) {
               		var pair = vars[i].split("=");
               		if(pair[0] == variable){return pair[1];}
       			}
      			 return(false);
			}

  $(function () {
    var path =getQueryVariable("path");
    path=decodeURI(path);
      var htmlobj = $.ajax({ url: "/" + path + "/info.txt", async: false });
      console.log("/" + path + "/info.txt");
      var v = htmlobj.responseText;
      var arrs = v.split("\r\n");
      console.log("数量："+arrs.length);
      for (var i = 0; i < arrs.length; i++) {
        if(arrs[i].includes("info.txt")||arrs[i].length==0||arrs[i].includes("a.bat")){
          console.log("空："+arrs[i]);
        }
        else if(path.includes("png")){    
          var path2="\\" + path + "\\"+arrs[i];
          var nextpage="\\" + path + "\\";
          var lastpage="\\" + path + "\\";
          if(arrs.length>(i+1)){
            var num2 = arrs[i].replace(/[^\d]/g, " ");
            nextpage="/" + path + "/"+arrs[i].replace(num2,num2+1);
          }else{

          }
          if(i-1>=0){
            lastpage=lastpage+arrs[i-1];
          }
          console.log("png:"+path2);
          $("#content").append("<a href='/pic.html?path=" +path2 + "&nextpage="+nextpage+"&lastpage="+lastpage+"' class='layui-btn layui-btn-normal'>" + arrs[i] + "</button>");
        }
       else{
        var path2=arrs[i];
          console.log("other:"+path2);
        }
      }

  })
</script>

</html>